<?php
$this->breadcrumbs = array(
	'凭证统计报表' => array(
		'stat'
	),
	'打印月总账'
);

?>

<h1 class="hide-print">打印月总账</h1>
<div class="form hide-print">
<?php $form = $this
	->beginWidget('CActiveForm',
		array(
			'action' => Yii::app()->createUrl($this->route),
			'method' => 'get',
		));
?>

<fieldset>
<legend>搜索条件</legend>

	<?php echo $form->errorSummary($statModel); ?>
	<div class="row">
		<?php echo $form->labelEx($statModel, 'projectId'); ?>
		<?php echo $form
			->dropDownList($statModel, 'projectId',
				CHtml::listData(AccountTokenProject::getAll(), 'id', 'name'),
				array(
					'empty' => '所有公司账目'
				));
		?>
		<?php echo $form->error($statModel, 'projectId'); ?>
	</div>
	<div class="row">
		<?php echo $form->label($statModel, 'tokenYear'); ?>
		<?php echo $form
			->dropDownList($statModel, 'tokenYear', AccountToken::findYears(),
				array(
					'empty' => '不限'
				));
		?>年
		<?php echo $form
			->dropDownList($statModel, 'tokenMonth', array_combine(range(1, 12), range(1, 12)),
				array(
					'empty' => '不限'
				));
		?>月
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($statModel, 'tokenDate'); ?>
		<?php $this
			->widget('zii.widgets.jui.CJuiDatePicker',
				array(
					'model' => $statModel,
					'attribute' => 'tokenDate',
				));
		?>
		<?php echo $form->error($statModel, 'tokenDate'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($statModel, 'number'); ?>
		<?php echo $form->textField($statModel, 'number');
		?>
		<?php echo $form->error($statModel, 'number'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($statModel, 'tokenNumberMin'); ?>
		<?php echo $form->textField($statModel, 'tokenNumberMin', array(
				'size' => 6
			));
		?> -
		<?php echo $form->textField($statModel, 'tokenNumberMax', array(
				'size' => 6
			));
		?>
	</div>
	<div class="row buttons">
		<?php echo CHtml::submitButton('确定'); ?>
	</div>

</fieldset>
<?php $this->endWidget(); ?>
</div>
<?php
if ($statModel->validate()) {
	$itemPerSection = 5;
	$items = $statModel->items;
	$pages = intval((count($items) - 1) / $itemPerSection) + 1;
	$i = 0;
?>
<div class="account-token-view">
<?php
	$stat = new stdClass();
	$stat->credit = 0;
	$stat->debit = 0;
	for ($page = 0; $page < $pages; $page++) {
?>
	<?php $this
				->renderPartial('_tokenSectionOverall',
					array(
						'model' => $statModel,
						'items' => array_slice($items, $page * $itemPerSection, $itemPerSection),
						'page' => $page + 1,
						'pages' => $pages,
						'itemPerSection' => $itemPerSection,
						'stat' => $stat
					));
	?>
<?php } ?>
</div>
<?php

}
?>
